uso de quarto

Author

Mayli Vargas Rojas

1 Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

1.1 Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

1 + 1
[1] 2

You can add options to executable code like this

[1] 4

The echo: false option disables the printing of code (only output is displayed).

1.2 fuentes

  • Negrita: esto es fuente negrita
  • Cursiva: Solanum tuberosum

1.3 formulas matemáticas

Este es el area de una circunferencia \(Area_c\ =\ pi\cdot r^2\)

Esta es una formula cualquiera \[\frac{\left(2x\ -\ 1\right)^2\ -\ 1}{4}\ =\ k\]

2 Mi primera página web

  1. Tener mi proyecto
  2. Conectar mi proyecto a Github
  3. Tener un archivo en formato html llamado index.html
  4. Hacer push al repositorio
  5. Activar Github pages

3 Modelos lineales mixtos

3.1 Importar datos

source('https://inkaverse.com/setup.r')
Warning: package 'cowplot' was built under R version 4.4.2
ℹ The googlesheets4 package is using a cached token for
  'smaylivrojas.10@gmail.com'.
ℹ The googledrive package is using a cached token for
  'smaylivrojas.10@gmail.com'.
gs4_auth(cache = ".secrets", email = "smaylivrojas.10@gmail.com")
#unlink(".secrets", recursive = TRUE)
#gs4_auth()
url <- "https://docs.google.com/spreadsheets/d/15r7ZwcZZHbEgltlF6gSFvCTFA-CFzVBWwg3mFlRyKPs/edit?gid=172957346#gid=172957346"

gs <- url %>% 
  as_sheets_id()

fb <- gs %>% 
  range_read("fb")
✔ Reading from "LA MOLINA 2014 POTATO WUE (FB)".
✔ Range ''fb''.
str(fb)
tibble [150 × 18] (S3: tbl_df/tbl/data.frame)
 $ riego  : chr [1:150] "sequia" "sequia" "irrigado" "sequia" ...
 $ geno   : chr [1:150] "G01" "G02" "G01" "G02" ...
 $ block  : num [1:150] 2 4 3 1 2 5 1 4 2 1 ...
 $ bloque : chr [1:150] "II" "IV" "III" "I" ...
 $ spad_29: num [1:150] 56.3 52.7 49.2 55.5 58.2 43.5 57.4 56.1 61 60.3 ...
 $ spad_83: num [1:150] 41.1 47.9 41.6 44.2 32.6 37.8 42.5 35.9 57.5 41.8 ...
 $ rwc_84 : num [1:150] 61.5 63.2 67.7 64.9 74.5 ...
 $ op_84  : num [1:150] -2.43 -3.03 -2.5 -2.4 -2.27 ...
 $ leafdw : num [1:150] 13.28 9.42 18.22 8.84 14.55 ...
 $ stemdw : num [1:150] 14.87 8.63 24.19 6.58 12.63 ...
 $ rootdw : num [1:150] 3.83 2.1 3.16 2 1.83 2.83 2.28 3.65 4.04 4.17 ...
 $ tubdw  : num [1:150] 19.8 17.7 38 13.5 51.1 ...
 $ biomdw : num [1:150] 51.8 37.8 83.6 30.9 80.2 ...
 $ hi     : num [1:150] 0.45 0.43 0.455 0.437 0.638 ...
 $ ttrans : num [1:150] 4.5 3.54 8.39 2.9 7.37 ...
 $ wue    : num [1:150] 11.51 10.69 9.97 10.65 10.88 ...
 $ twue   : num [1:150] 4.4 4.99 4.53 4.65 6.94 ...
 $ lfa    : num [1:150] 2900 2619 7579 2450 5413 ...

4 Modelo lineal lfa

modelo <- aov(formula = lfa ~  bloque + riego + geno + riego*geno
              , data = fb)

anova(modelo)
## Analysis of Variance Table
## 
## Response: lfa
##             Df    Sum Sq   Mean Sq   F value              Pr(>F)    
## bloque       4   3435339    858835    1.5616              0.1892    
## riego        1 788556926 788556926 1433.7957 <0.0000000000000002 ***
## geno        14 261729564  18694969   33.9922 <0.0000000000000002 ***
## riego:geno  14 108147972   7724855   14.0457 <0.0000000000000002 ***
## Residuals  116  63797516    549979                                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

plot(modelo)

4.1 boxplot


ggplot(fb, aes(x = geno, y = lfa, colour = riego)) +
  geom_boxplot(outlier.colour = "red", outlier.shape = 16, outlier.size = 2) +
  labs(title = "Boxplot con interacción de niveles de riego y genotipo",
       x = "Interacción Riego y Genotipo",
       y = "Area Folicar (cm^2)")

theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Inclinar etiquetas del eje X
## List of 136
##  $ line                            :List of 6
##   ..$ colour       : chr "black"
##   ..$ linewidth    : num 0.5
##   ..$ linetype     : num 1
##   ..$ lineend      : chr "butt"
##   ..$ arrow        : logi FALSE
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_line" "element"
##  $ rect                            :List of 5
##   ..$ fill         : chr "white"
##   ..$ colour       : chr "black"
##   ..$ linewidth    : num 0.5
##   ..$ linetype     : num 1
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_rect" "element"
##  $ text                            :List of 11
##   ..$ family       : chr ""
##   ..$ face         : chr "plain"
##   ..$ colour       : chr "black"
##   ..$ size         : num 11
##   ..$ hjust        : num 0.5
##   ..$ vjust        : num 0.5
##   ..$ angle        : num 0
##   ..$ lineheight   : num 0.9
##   ..$ margin       : 'margin' num [1:4] 0points 0points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : logi FALSE
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ title                           : NULL
##  $ aspect.ratio                    : NULL
##  $ axis.title                      : NULL
##  $ axis.title.x                    :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 1
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 2.75points 0points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.x.top                :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 0
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 2.75points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.x.bottom             : NULL
##  $ axis.title.y                    :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 1
##   ..$ angle        : num 90
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 2.75points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.y.left               : NULL
##  $ axis.title.y.right              :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 1
##   ..$ angle        : num -90
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 0points 2.75points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text                       :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : chr "grey30"
##   ..$ size         : 'rel' num 0.8
##   ..$ hjust        : NULL
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x                     :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 1
##   ..$ vjust        : num 1
##   ..$ angle        : num 45
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 2.2points 0points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi FALSE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x.top                 :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 0
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 2.2points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x.bottom              : NULL
##  $ axis.text.y                     :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 1
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 2.2points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.y.left                : NULL
##  $ axis.text.y.right               :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 0
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 0points 2.2points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.theta                 : NULL
##  $ axis.text.r                     :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 0.5
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 2.2points 0points 2.2points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.ticks                      : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ axis.ticks.x                    : NULL
##  $ axis.ticks.x.top                : NULL
##  $ axis.ticks.x.bottom             : NULL
##  $ axis.ticks.y                    : NULL
##  $ axis.ticks.y.left               : NULL
##  $ axis.ticks.y.right              : NULL
##  $ axis.ticks.theta                : NULL
##  $ axis.ticks.r                    : NULL
##  $ axis.minor.ticks.x.top          : NULL
##  $ axis.minor.ticks.x.bottom       : NULL
##  $ axis.minor.ticks.y.left         : NULL
##  $ axis.minor.ticks.y.right        : NULL
##  $ axis.minor.ticks.theta          : NULL
##  $ axis.minor.ticks.r              : NULL
##  $ axis.ticks.length               : 'simpleUnit' num 2.75points
##   ..- attr(*, "unit")= int 8
##  $ axis.ticks.length.x             : NULL
##  $ axis.ticks.length.x.top         : NULL
##  $ axis.ticks.length.x.bottom      : NULL
##  $ axis.ticks.length.y             : NULL
##  $ axis.ticks.length.y.left        : NULL
##  $ axis.ticks.length.y.right       : NULL
##  $ axis.ticks.length.theta         : NULL
##  $ axis.ticks.length.r             : NULL
##  $ axis.minor.ticks.length         : 'rel' num 0.75
##  $ axis.minor.ticks.length.x       : NULL
##  $ axis.minor.ticks.length.x.top   : NULL
##  $ axis.minor.ticks.length.x.bottom: NULL
##  $ axis.minor.ticks.length.y       : NULL
##  $ axis.minor.ticks.length.y.left  : NULL
##  $ axis.minor.ticks.length.y.right : NULL
##  $ axis.minor.ticks.length.theta   : NULL
##  $ axis.minor.ticks.length.r       : NULL
##  $ axis.line                       : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ axis.line.x                     : NULL
##  $ axis.line.x.top                 : NULL
##  $ axis.line.x.bottom              : NULL
##  $ axis.line.y                     : NULL
##  $ axis.line.y.left                : NULL
##  $ axis.line.y.right               : NULL
##  $ axis.line.theta                 : NULL
##  $ axis.line.r                     : NULL
##  $ legend.background               : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ legend.margin                   : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
##   ..- attr(*, "unit")= int 8
##  $ legend.spacing                  : 'simpleUnit' num 11points
##   ..- attr(*, "unit")= int 8
##  $ legend.spacing.x                : NULL
##  $ legend.spacing.y                : NULL
##  $ legend.key                      : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ legend.key.size                 : 'simpleUnit' num 1.2lines
##   ..- attr(*, "unit")= int 3
##  $ legend.key.height               : NULL
##  $ legend.key.width                : NULL
##  $ legend.key.spacing              : 'simpleUnit' num 5.5points
##   ..- attr(*, "unit")= int 8
##  $ legend.key.spacing.x            : NULL
##  $ legend.key.spacing.y            : NULL
##  $ legend.frame                    : NULL
##  $ legend.ticks                    : NULL
##  $ legend.ticks.length             : 'rel' num 0.2
##  $ legend.axis.line                : NULL
##  $ legend.text                     :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : 'rel' num 0.8
##   ..$ hjust        : NULL
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.text.position            : NULL
##  $ legend.title                    :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 0
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.title.position           : NULL
##  $ legend.position                 : chr "right"
##  $ legend.position.inside          : NULL
##  $ legend.direction                : NULL
##  $ legend.byrow                    : NULL
##  $ legend.justification            : chr "center"
##  $ legend.justification.top        : NULL
##  $ legend.justification.bottom     : NULL
##  $ legend.justification.left       : NULL
##  $ legend.justification.right      : NULL
##  $ legend.justification.inside     : NULL
##  $ legend.location                 : NULL
##  $ legend.box                      : NULL
##  $ legend.box.just                 : NULL
##  $ legend.box.margin               : 'margin' num [1:4] 0cm 0cm 0cm 0cm
##   ..- attr(*, "unit")= int 1
##  $ legend.box.background           : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ legend.box.spacing              : 'simpleUnit' num 11points
##   ..- attr(*, "unit")= int 8
##   [list output truncated]
##  - attr(*, "class")= chr [1:2] "theme" "gg"
##  - attr(*, "complete")= logi TRUE
##  - attr(*, "validate")= logi TRUE

5 Modelo lineal: hi

modelo <- aov(formula = hi ~  bloque + riego + geno + riego*geno
              , data = fb)

anova(modelo)
## Analysis of Variance Table
## 
## Response: hi
##             Df  Sum Sq  Mean Sq F value                Pr(>F)    
## bloque       4 0.09111 0.022778  7.0747         0.00003925028 ***
## riego        1 0.12176 0.121758 37.8165         0.00000001135 ***
## geno        14 2.70077 0.192912 59.9161 < 0.00000000000000022 ***
## riego:geno  14 0.07762 0.005544  1.7219               0.06019 .  
## Residuals  116 0.37349 0.003220                                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

plot(modelo)

6 Modelo lineal mixto: lfa

library(lme4)
library(lmerTest)

model <- lme4::lmer(lfa ~ riego + geno + riego*geno + (1|bloque), data = fb)

anova(model)
## Analysis of Variance Table
##            npar    Sum Sq   Mean Sq  F value
## riego         1 788556926 788556926 1433.796
## geno         14 261729564  18694969   33.992
## riego:geno   14 108147972   7724855   14.046

plot(modelo)



ol <- boxplot(lfa ~ riego*geno, fb)

ol
## $stats
##         [,1]    [,2]    [,3]    [,4]    [,5]    [,6]     [,7]    [,8]     [,9]
## [1,] 6539.86 2900.00 4631.00 2449.59 5305.77 1811.97  8569.08 2511.13  7205.94
## [2,] 7038.08 2994.58 5162.74 2487.28 5369.88 1953.50  8867.03 2889.83  8189.67
## [3,] 7578.79 2999.66 5233.55 2618.85 5412.51 2107.76  9791.10 3010.27  8913.12
## [4,] 7750.00 3100.00 6478.14 2966.18 5450.00 2147.55 10305.61 3218.63  9793.99
## [5,] 7982.73 3203.70 7392.38 3063.35 5545.69 2274.48 10811.84 3263.70 10291.06
##        [,10]   [,11]   [,12]   [,13]   [,14]   [,15]   [,16]    [,17]   [,18]
## [1,] 1657.64 6576.65 3159.54 1065.26  216.31 6998.00 2021.37  8533.54 2781.32
## [2,] 1700.00 6857.13 3198.96 1068.97  495.83 7012.74 2278.60  8924.78 2961.78
## [3,] 1771.80 6938.90 3381.68 1140.05  782.10 7310.01 2319.71 10764.71 3150.00
## [4,] 1821.46 7864.08 3450.00 1607.25  811.45 7469.58 2550.51 10919.31 3235.10
## [5,] 1967.49 9040.06 3550.19 1989.25 1097.98 7643.80 2697.93 12296.22 3238.41
##        [,19]   [,20]   [,21]   [,22]   [,23]   [,24]   [,25]   [,26]   [,27]
## [1,] 4249.18 2909.10 3966.33 1556.38 6111.43 2400.00 7180.79 3062.34 6049.52
## [2,] 4743.16 2909.10 6210.41 1942.23 7164.03 2425.26 8256.98 3110.00 7895.00
## [3,] 5171.21 2940.95 7225.02 2237.88 7194.26 2438.98 8750.00 3120.00 8978.89
## [4,] 6028.93 3096.00 8005.55 2274.26 8012.79 2480.00 9430.43 3146.19 9221.24
## [5,] 6164.24 3136.07 8867.09 2301.31 8603.78 2487.78 9743.70 3191.97 9776.01
##        [,28]   [,29]   [,30]
## [1,] 3318.36 6270.00 1560.00
## [2,] 3326.93 6302.79 1560.00
## [3,] 3449.76 6304.88 1601.06
## [4,] 3664.65 6435.00 1750.00
## [5,] 3811.99 6522.46 1814.84
## 
## $n
##  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
## 
## $conf
##          [,1]    [,2]     [,3]    [,4]     [,5]     [,6]      [,7]     [,8]
## [1,] 7075.749 2925.17 4304.092 2280.46 5355.897 1970.645  8774.603 2777.941
## [2,] 8081.831 3074.15 6163.008 2957.24 5469.123 2244.875 10807.597 3242.599
##           [,9]    [,10]    [,11]    [,12]     [,13]     [,14]    [,15]    [,16]
## [1,]  7779.512 1685.977 6227.392 3204.296  759.7027  559.0837 6987.208 2127.579
## [2,] 10046.728 1857.623 7650.408 3559.064 1520.3973 1005.1163 7632.812 2511.841
##         [,17]    [,18]    [,19]    [,20]    [,21]    [,22]    [,23]    [,24]
## [1,]  9355.38 2956.873 4262.688 2808.887 5956.579 2003.268 6594.528 2400.301
## [2,] 12174.04 3343.127 6079.732 3073.013 8493.461 2472.492 7793.992 2477.659
##         [,25]    [,26]    [,27]    [,28]    [,29]    [,30]
## [1,] 7920.843 3094.428 8041.772 3211.128 6211.461 1466.806
## [2,] 9579.157 3145.572 9916.008 3688.392 6398.299 1735.314
## 
## $out
## [1] 2541.12 1176.63
## 
## $group
## [1] 20 30
## 
## $names
##  [1] "irrigado.G01" "sequia.G01"   "irrigado.G02" "sequia.G02"   "irrigado.G03"
##  [6] "sequia.G03"   "irrigado.G04" "sequia.G04"   "irrigado.G05" "sequia.G05"  
## [11] "irrigado.G06" "sequia.G06"   "irrigado.G07" "sequia.G07"   "irrigado.G08"
## [16] "sequia.G08"   "irrigado.G09" "sequia.G09"   "irrigado.G10" "sequia.G10"  
## [21] "irrigado.G11" "sequia.G11"   "irrigado.G12" "sequia.G12"   "irrigado.G13"
## [26] "sequia.G13"   "irrigado.G14" "sequia.G14"   "irrigado.G15" "sequia.G15"
library(inti)

model <- remove_outliers(data = fb
                         , formula = lfa ~ riego + geno + riego*geno + (1|bloque)
                         , plot_diag = T
)

model
## $data
## $data$raw
## # A tibble: 150 × 5
##    index riego    geno  bloque   lfa
##    <chr> <chr>    <chr> <chr>  <dbl>
##  1 1     sequia   G01   II     2900 
##  2 2     sequia   G02   IV     2619.
##  3 3     irrigado G01   III    7579.
##  4 4     sequia   G02   I      2450.
##  5 5     irrigado G03   II     5413.
##  6 6     irrigado G04   V      9791.
##  7 7     irrigado G01   I      7038.
##  8 8     irrigado G05   IV     9794.
##  9 9     sequia   G06   II     3199.
## 10 10    sequia   G05   I      1658.
## # ℹ 140 more rows
## 
## $data$clean
##     index    riego geno bloque      lfa
## 1       1   sequia  G01     II  2900.00
## 2       2   sequia  G02     IV  2618.85
## 3       3 irrigado  G01    III  7578.79
## 4       4   sequia  G02      I  2449.59
## 5       5 irrigado  G03     II  5412.51
## 6       6 irrigado  G04      V  9791.10
## 7       7 irrigado  G01      I  7038.08
## 8       8 irrigado  G05     IV  9793.99
## 9       9   sequia  G06     II  3198.96
## 10     10   sequia  G05      I  1657.64
## 11     11 irrigado  G01     II  7982.73
## 12     12   sequia  G07     II  1097.98
## 13     13 irrigado  G08     II  7310.01
## 14     14 irrigado  G06    III  6576.65
## 15     15 irrigado  G09    III 10764.71
## 16     16 irrigado  G10     II  5171.21
## 17     17   sequia  G11      I  1556.38
## 18     18   sequia  G12    III  2425.26
## 19     19 irrigado  G07      I  1065.26
## 20     20 irrigado  G04     II 10811.84
## 21     21 irrigado  G13     II  9743.70
## 22     22 irrigado  G14    III  7895.00
## 23     23 irrigado  G04     IV 10305.61
## 24     24   sequia  G04      V  3218.63
## 25     25   sequia  G08      V  2697.93
## 26     26   sequia  G04    III  3263.70
## 27     27   sequia  G01     IV  2994.58
## 28     28 irrigado  G10      I  6164.24
## 29     29 irrigado  G08      V  7469.58
## 30     30 irrigado  G02      V  5233.55
## 31     31 irrigado  G07    III  1607.25
## 32     32 irrigado  G08      I  6998.00
## 33     33 irrigado  G14      V  8978.89
## 34     34 irrigado  G03      I  5545.69
## 35     35   sequia  G13    III  3120.00
## 36     36   sequia  G01      V  2999.66
## 37     37   sequia  G03      I  2274.48
## 38     38 irrigado  G15    III  6302.79
## 39     39 irrigado  G03     IV  5305.77
## 40     40 irrigado  G09     IV       NA
## 41     41 irrigado  G11     II       NA
## 42     42   sequia  G03      V  2147.55
## 43     43   sequia  G11    III  2301.31
## 44     44 irrigado  G06      V       NA
## 45     45   sequia  G05      V  1771.80
## 46     46   sequia  G08     IV  2021.37
## 47     47 irrigado  G11     IV  8005.55
## 48     48   sequia  G11     II  1942.23
## 49     49 irrigado  G10    III  6028.93
## 50     50   sequia  G06     IV  3550.19
## 51     51   sequia  G09      I  3238.41
## 52     52 irrigado  G11      I  6210.41
## 53     53   sequia  G11     IV  2237.88
## 54     54 irrigado  G15     IV  6270.00
## 55     55 irrigado  G13     IV  9430.43
## 56     56   sequia  G14      V  3664.65
## 57     57 irrigado  G02     IV       NA
## 58     58 irrigado  G09     II       NA
## 59     59 irrigado  G02    III  5162.74
## 60     60   sequia  G08    III  2550.51
## 61     61 irrigado  G06     II  6938.90
## 62     62   sequia  G13     IV  3062.34
## 63     63   sequia  G14    III  3449.76
## 64     64   sequia  G04     II  2511.13
## 65     65 irrigado  G11    III       NA
## 66     66 irrigado  G07     II  1068.97
## 67     67 irrigado  G08     IV  7643.80
## 68     68   sequia  G05     IV  1821.46
## 69     69 irrigado  G04      I  8569.08
## 70     70 irrigado  G11      V  7225.02
## 71     71 irrigado  G12      I  7194.26
## 72     72   sequia  G14     IV  3318.36
## 73     73   sequia  G07    III   811.45
## 74     74 irrigado  G03    III  5450.00
## 75     75   sequia  G01      I  3100.00
## 76     76   sequia  G04      I  3010.27
## 77     77   sequia  G03     II  2107.76
## 78     78 irrigado  G15     II  6304.88
## 79     79   sequia  G12     IV  2480.00
## 80     80   sequia  G12      I  2400.00
## 81     81   sequia  G08      I  2319.71
## 82     82   sequia  G05     II  1700.00
## 83     83   sequia  G02     II  2966.18
## 84     84   sequia  G10      I  3136.07
## 85     85   sequia  G15      I  1814.84
## 86     86 irrigado  G07      V  1140.05
## 87     87   sequia  G10      V  2909.10
## 88     88   sequia  G13     II  3110.00
## 89     89   sequia  G07      V   495.83
## 90     90   sequia  G03    III  1953.50
## 91     91   sequia  G15     IV  1750.00
## 92     92   sequia  G13      I  3191.97
## 93     93   sequia  G03     IV  1811.97
## 94     94 irrigado  G10      V  4249.18
## 95     95   sequia  G13      V  3146.19
## 96     96   sequia  G09     II  3235.10
## 97     97 irrigado  G14     IV       NA
## 98     98 irrigado  G01      V  6539.86
## 99     99   sequia  G01    III  3203.70
## 100   100 irrigado  G06     IV  7864.08
## 101   101   sequia  G04     IV  2889.83
## 102   102 irrigado  G15      V  6522.46
## 103   103 irrigado  G13    III       NA
## 104   104 irrigado  G02     II  6478.14
## 105   105   sequia  G08     II  2278.60
## 106   106 irrigado  G04    III  8867.03
## 107   107   sequia  G02      V  3063.35
## 108   108   sequia  G06      V  3159.54
## 109   109 irrigado  G15      I  6435.00
## 110   110 irrigado  G13      V  8750.00
## 111   111 irrigado  G05      V  8189.67
## 112   112   sequia  G09    III  2961.78
## 113   113   sequia  G09      V  2781.32
## 114   114   sequia  G10     II  2940.95
## 115   115 irrigado  G07     IV  1989.25
## 116   116 irrigado  G05      I       NA
## 117   117 irrigado  G02      I  4631.00
## 118   118   sequia  G05    III  1967.49
## 119   119 irrigado  G12     II       NA
## 120   120   sequia  G15    III  1601.06
## 121   121 irrigado  G13      I  8256.98
## 122   122   sequia  G14     II  3811.99
## 123   123   sequia  G12     II  2438.98
## 124   124   sequia  G15     II  1560.00
## 125   125 irrigado  G09      V       NA
## 126   126   sequia  G06      I  3381.68
## 127   127   sequia  G09     IV  3150.00
## 128   128   sequia  G15      V  1176.63
## 129   129 irrigado  G14      I       NA
## 130   130   sequia  G06    III  3450.00
## 131   131 irrigado  G01     IV  7750.00
## 132   132 irrigado  G12    III  7164.03
## 133   133   sequia  G12      V  2487.78
## 134   134 irrigado  G12      V  8603.78
## 135   135   sequia  G11      V  2274.26
## 136   136 irrigado  G12     IV  8012.79
## 137   137 irrigado  G09      I 10919.31
## 138   138   sequia  G02    III  2487.28
## 139   139   sequia  G07      I   216.31
## 140   140 irrigado  G08    III  7012.74
## 141   141 irrigado  G06      I  6857.13
## 142   142 irrigado  G10     IV  4743.16
## 143   143 irrigado  G03      V  5369.88
## 144   144   sequia  G07     IV   782.10
## 145   145 irrigado  G05    III  8913.12
## 146   146   sequia  G14      I  3326.93
## 147   147   sequia  G10    III  3096.00
## 148   148 irrigado  G14     II  9221.24
## 149   149 irrigado  G05     II       NA
## 150   150   sequia  G10     IV  2541.12
## 
## 
## $outliers
##     index    riego geno bloque      lfa      resi   res_MAD         rawp.BHStud
## 40     40 irrigado  G09     IV  8533.54 -1821.843 -5.382198 0.00000007358196186
## 41     41 irrigado  G11     II  3966.33 -2921.009 -8.629420 0.00000000000000000
## 44     44 irrigado  G06      V  9040.06  1586.844  4.687948 0.00000275958224139
## 57     57 irrigado  G02     IV  7392.38  1545.147  4.564765 0.00000500053779318
## 58     58 irrigado  G09     II 12296.22  1976.049  5.837760 0.00000000529071831
## 65     65 irrigado  G11    III  8867.09  2014.449  5.951205 0.00000000266175237
## 97     97 irrigado  G14     IV  9776.01  1324.207  3.912051 0.00009151556329234
## 103   103 irrigado  G13    III  7180.79 -1489.351 -4.399930 0.00001082858978219
## 116   116 irrigado  G05      I  7205.94 -1577.072 -4.659080 0.00000317625961999
## 119   119 irrigado  G12     II  6111.43 -1338.287 -3.953649 0.00007696837896431
## 125   125 irrigado  G09      V  8924.78 -1360.784 -4.020111 0.00005817084375703
## 129   129 irrigado  G14      I  6049.52 -2238.868 -6.614197 0.00000000003735745
## 149   149 irrigado  G05     II 10291.06  1379.845  4.076419 0.00004573459036372
##                    adjp            bholm out_flag
## 40  0.00000007358196186 0.00001074296643  OUTLIER
## 41  0.00000000000000000 0.00000000000000  OUTLIER
## 44  0.00000275958224139 0.00040013942500  OUTLIER
## 57  0.00000500053779318 0.00071507690442  OUTLIER
## 58  0.00000000529071831 0.00000077773559  OUTLIER
## 65  0.00000000266175237 0.00000039393935  OUTLIER
## 97  0.00009151556329234 0.01262914773434  OUTLIER
## 103 0.00001082858978219 0.00153765974907  OUTLIER
## 116 0.00000317625961999 0.00045738138528  OUTLIER
## 119 0.00007696837896431 0.01069860467604  OUTLIER
## 125 0.00005817084375703 0.00814391812598  OUTLIER
## 129 0.00000000003735745 0.00000000556626  OUTLIER
## 149 0.00004573459036372 0.00644857724128  OUTLIER
## 
## $diagplot

## 
## $model
## $model$raw
## Linear mixed model fit by REML ['lmerMod']
## Formula: lfa ~ riego + geno + riego * geno + (1 | bloque)
##    Data: rawdt
## REML criterion at convergence: 1976.727
## Random effects:
##  Groups   Name        Std.Dev.
##  bloque   (Intercept) 101.5   
##  Residual             741.6   
## Number of obs: 150, groups:  bloque, 5
## Fixed Effects:
##         (Intercept)          riegosequia              genoG02  
##             7377.89             -4338.30             -1598.33  
##             genoG03              genoG04              genoG05  
##            -1961.12              2291.04              1500.86  
##             genoG06              genoG07              genoG08  
##               77.47             -6003.74               -91.07  
##             genoG09              genoG10              genoG11  
##             2909.82             -2106.55              -523.01  
##             genoG12              genoG13              genoG14  
##               39.37              1294.49              1006.24  
##             genoG15  riegosequia:genoG02  riegosequia:genoG03  
##            -1010.87              1275.79               980.59  
## riegosequia:genoG04  riegosequia:genoG05  riegosequia:genoG06  
##            -2351.92             -2756.77               231.01  
## riegosequia:genoG07  riegosequia:genoG08  riegosequia:genoG09  
##             3644.88              -574.90             -2876.09  
## riegosequia:genoG10  riegosequia:genoG11  riegosequia:genoG12  
##             1991.61              -454.16              -632.55  
## riegosequia:genoG13  riegosequia:genoG14  riegosequia:genoG15  
##            -1207.98              -531.49              -448.22  
## 
## $model$clean
## Linear mixed model fit by REML ['lmerMod']
## Formula: lfa ~ riego + geno + riego * geno + (1 | bloque)
##    Data: cleandt
## REML criterion at convergence: 1651.184
## Random effects:
##  Groups   Name        Std.Dev.
##  bloque   (Intercept) 106.6   
##  Residual             432.2   
## Number of obs: 137, groups:  bloque, 5
## Fixed Effects:
##         (Intercept)          riegosequia              genoG02  
##             7377.89             -4338.30             -1980.26  
##             genoG03              genoG04              genoG05  
##            -1961.12              2291.04              1579.63  
##             genoG06              genoG07              genoG08  
##             -326.74             -6003.74               -91.07  
##             genoG09              genoG10              genoG11  
##             3532.95             -2106.55              -212.24  
##             genoG12              genoG13              genoG14  
##              387.00              1660.20              1312.54  
##             genoG15  riegosequia:genoG02  riegosequia:genoG03  
##            -1010.87              1657.73               980.59  
## riegosequia:genoG04  riegosequia:genoG05  riegosequia:genoG06  
##            -2351.92             -2835.54               635.22  
## riegosequia:genoG07  riegosequia:genoG08  riegosequia:genoG09  
##             3644.88              -574.90             -3499.22  
## riegosequia:genoG10  riegosequia:genoG11  riegosequia:genoG12  
##             1991.61              -764.94              -980.19  
## riegosequia:genoG13  riegosequia:genoG14  riegosequia:genoG15  
##            -1573.69              -837.79              -448.22

7 Comparacion de medias

modelo <- lm(formula = lfa ~  bloque + riego + geno + riego*geno
             , data = fb)

anova(modelo)
## Analysis of Variance Table
## 
## Response: lfa
##             Df    Sum Sq   Mean Sq   F value              Pr(>F)    
## bloque       4   3435339    858835    1.5616              0.1892    
## riego        1 788556926 788556926 1433.7957 <0.0000000000000002 ***
## geno        14 261729564  18694969   33.9922 <0.0000000000000002 ***
## riego:geno  14 108147972   7724855   14.0457 <0.0000000000000002 ***
## Residuals  116  63797516    549979                                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

library(agricolae)

tukey_result <- HSD.test(modelo
                         , c("geno", "riego")
                         , group = TRUE)
tukey_result
## $statistics
##    MSerror  Df     Mean       CV      MSD
##   549978.6 116 4806.708 15.42855 1803.603
## 
## $parameters
##    test     name.t ntr StudentizedRange alpha
##   Tukey geno:riego  30         5.438172  0.05
## 
## $means
##                    lfa        std r      se     Min      Max     Q25      Q50
## G01:irrigado  7377.892  583.61443 5 331.656 6539.86  7982.73 7038.08  7578.79
## G01:sequia    3039.588  115.85242 5 331.656 2900.00  3203.70 2994.58  2999.66
## G02:irrigado  5779.562 1127.71742 5 331.656 4631.00  7392.38 5162.74  5233.55
## G02:sequia    2717.050  281.05239 5 331.656 2449.59  3063.35 2487.28  2618.85
## G03:irrigado  5416.770   89.80871 5 331.656 5305.77  5545.69 5369.88  5412.51
## G03:sequia    2059.052  179.44660 5 331.656 1811.97  2274.48 1953.50  2107.76
## G04:irrigado  9668.932  945.94448 5 331.656 8569.08 10811.84 8867.03  9791.10
## G04:sequia    2978.712  302.61678 5 331.656 2511.13  3263.70 2889.83  3010.27
## G05:irrigado  8878.756 1235.57574 5 331.656 7205.94 10291.06 8189.67  8913.12
## G05:sequia    1783.678  120.66794 5 331.656 1657.64  1967.49 1700.00  1771.80
## G06:irrigado  7455.364 1009.33982 5 331.656 6576.65  9040.06 6857.13  6938.90
## G06:sequia    3348.074  165.94367 5 331.656 3159.54  3550.19 3198.96  3381.68
## G07:irrigado  1374.156  411.10652 5 331.656 1065.26  1989.25 1068.97  1140.05
## G07:sequia     680.734  335.90739 5 331.656  216.31  1097.98  495.83   782.10
## G08:irrigado  7286.826  282.80318 5 331.656 6998.00  7643.80 7012.74  7310.01
## G08:sequia    2373.624  260.99914 5 331.656 2021.37  2697.93 2278.60  2319.71
## G09:irrigado 10287.712 1548.81007 5 331.656 8533.54 12296.22 8924.78 10764.71
## G09:sequia    3073.322  198.12400 5 331.656 2781.32  3238.41 2961.78  3150.00
## G10:irrigado  5271.344  822.34789 5 331.656 4249.18  6164.24 4743.16  5171.21
## G10:sequia    2924.648  235.40497 5 331.656 2541.12  3136.07 2909.10  2940.95
## G11:irrigado  6854.880 1888.72290 5 331.656 3966.33  8867.09 6210.41  7225.02
## G11:sequia    2062.412  317.51100 5 331.656 1556.38  2301.31 1942.23  2237.88
## G12:irrigado  7417.258  946.24681 5 331.656 6111.43  8603.78 7164.03  7194.26
## G12:sequia    2446.404   37.06811 5 331.656 2400.00  2487.78 2425.26  2438.98
## G13:irrigado  8672.380 1015.60193 5 331.656 7180.79  9743.70 8256.98  8750.00
## G13:sequia    3126.100   47.70803 5 331.656 3062.34  3191.97 3110.00  3120.00
## G14:irrigado  8384.132 1473.21710 5 331.656 6049.52  9776.01 7895.00  8978.89
## G14:sequia    3514.338  217.30731 5 331.656 3318.36  3811.99 3326.93  3449.76
## G15:irrigado  6367.026  107.45072 5 331.656 6270.00  6522.46 6302.79  6304.88
## G15:sequia    1580.506  248.79682 5 331.656 1176.63  1814.84 1560.00  1601.06
##                   Q75
## G01:irrigado  7750.00
## G01:sequia    3100.00
## G02:irrigado  6478.14
## G02:sequia    2966.18
## G03:irrigado  5450.00
## G03:sequia    2147.55
## G04:irrigado 10305.61
## G04:sequia    3218.63
## G05:irrigado  9793.99
## G05:sequia    1821.46
## G06:irrigado  7864.08
## G06:sequia    3450.00
## G07:irrigado  1607.25
## G07:sequia     811.45
## G08:irrigado  7469.58
## G08:sequia    2550.51
## G09:irrigado 10919.31
## G09:sequia    3235.10
## G10:irrigado  6028.93
## G10:sequia    3096.00
## G11:irrigado  8005.55
## G11:sequia    2274.26
## G12:irrigado  8012.79
## G12:sequia    2480.00
## G13:irrigado  9430.43
## G13:sequia    3146.19
## G14:irrigado  9221.24
## G14:sequia    3664.65
## G15:irrigado  6435.00
## G15:sequia    1750.00
## 
## $comparison
## NULL
## 
## $groups
##                    lfa groups
## G09:irrigado 10287.712      a
## G04:irrigado  9668.932     ab
## G05:irrigado  8878.756    abc
## G13:irrigado  8672.380    abc
## G14:irrigado  8384.132    bcd
## G06:irrigado  7455.364    cde
## G12:irrigado  7417.258    cde
## G01:irrigado  7377.892    cde
## G08:irrigado  7286.826    cde
## G11:irrigado  6854.880    def
## G15:irrigado  6367.026     ef
## G02:irrigado  5779.562     ef
## G03:irrigado  5416.770      f
## G10:irrigado  5271.344     fg
## G14:sequia    3514.338     gh
## G06:sequia    3348.074     hi
## G13:sequia    3126.100    hij
## G09:sequia    3073.322    hij
## G01:sequia    3039.588    hij
## G04:sequia    2978.712    hij
## G10:sequia    2924.648    hij
## G02:sequia    2717.050    hij
## G12:sequia    2446.404   hijk
## G08:sequia    2373.624   hijk
## G11:sequia    2062.412   hijk
## G03:sequia    2059.052   hijk
## G05:sequia    1783.678   hijk
## G15:sequia    1580.506    ijk
## G07:irrigado  1374.156     jk
## G07:sequia     680.734      k
## 
## attr(,"class")
## [1] "group"

plot(tukey_result)


str(tukey_result)
## List of 5
##  $ statistics:'data.frame':  1 obs. of  5 variables:
##   ..$ MSerror: num 549979
##   ..$ Df     : int 116
##   ..$ Mean   : num 4807
##   ..$ CV     : num 15.4
##   ..$ MSD    : num 1804
##  $ parameters:'data.frame':  1 obs. of  5 variables:
##   ..$ test            : chr "Tukey"
##   ..$ name.t          : chr "geno:riego"
##   ..$ ntr             : int 30
##   ..$ StudentizedRange: num 5.44
##   ..$ alpha           : num 0.05
##  $ means     :'data.frame':  30 obs. of  9 variables:
##   ..$ lfa: num [1:30] 7378 3040 5780 2717 5417 ...
##   ..$ std: num [1:30] 583.6 115.9 1127.7 281.1 89.8 ...
##   ..$ r  : int [1:30] 5 5 5 5 5 5 5 5 5 5 ...
##   ..$ se : num [1:30] 332 332 332 332 332 ...
##   ..$ Min: num [1:30] 6540 2900 4631 2450 5306 ...
##   ..$ Max: num [1:30] 7983 3204 7392 3063 5546 ...
##   ..$ Q25: num [1:30] 7038 2995 5163 2487 5370 ...
##   ..$ Q50: num [1:30] 7579 3000 5234 2619 5413 ...
##   ..$ Q75: num [1:30] 7750 3100 6478 2966 5450 ...
##  $ comparison: NULL
##  $ groups    :'data.frame':  30 obs. of  2 variables:
##   ..$ lfa   : num [1:30] 10288 9669 8879 8672 8384 ...
##   ..$ groups: chr [1:30] "a" "ab" "abc" "abc" ...
##  - attr(*, "class")= chr "group"

tukey_result
## $statistics
##    MSerror  Df     Mean       CV      MSD
##   549978.6 116 4806.708 15.42855 1803.603
## 
## $parameters
##    test     name.t ntr StudentizedRange alpha
##   Tukey geno:riego  30         5.438172  0.05
## 
## $means
##                    lfa        std r      se     Min      Max     Q25      Q50
## G01:irrigado  7377.892  583.61443 5 331.656 6539.86  7982.73 7038.08  7578.79
## G01:sequia    3039.588  115.85242 5 331.656 2900.00  3203.70 2994.58  2999.66
## G02:irrigado  5779.562 1127.71742 5 331.656 4631.00  7392.38 5162.74  5233.55
## G02:sequia    2717.050  281.05239 5 331.656 2449.59  3063.35 2487.28  2618.85
## G03:irrigado  5416.770   89.80871 5 331.656 5305.77  5545.69 5369.88  5412.51
## G03:sequia    2059.052  179.44660 5 331.656 1811.97  2274.48 1953.50  2107.76
## G04:irrigado  9668.932  945.94448 5 331.656 8569.08 10811.84 8867.03  9791.10
## G04:sequia    2978.712  302.61678 5 331.656 2511.13  3263.70 2889.83  3010.27
## G05:irrigado  8878.756 1235.57574 5 331.656 7205.94 10291.06 8189.67  8913.12
## G05:sequia    1783.678  120.66794 5 331.656 1657.64  1967.49 1700.00  1771.80
## G06:irrigado  7455.364 1009.33982 5 331.656 6576.65  9040.06 6857.13  6938.90
## G06:sequia    3348.074  165.94367 5 331.656 3159.54  3550.19 3198.96  3381.68
## G07:irrigado  1374.156  411.10652 5 331.656 1065.26  1989.25 1068.97  1140.05
## G07:sequia     680.734  335.90739 5 331.656  216.31  1097.98  495.83   782.10
## G08:irrigado  7286.826  282.80318 5 331.656 6998.00  7643.80 7012.74  7310.01
## G08:sequia    2373.624  260.99914 5 331.656 2021.37  2697.93 2278.60  2319.71
## G09:irrigado 10287.712 1548.81007 5 331.656 8533.54 12296.22 8924.78 10764.71
## G09:sequia    3073.322  198.12400 5 331.656 2781.32  3238.41 2961.78  3150.00
## G10:irrigado  5271.344  822.34789 5 331.656 4249.18  6164.24 4743.16  5171.21
## G10:sequia    2924.648  235.40497 5 331.656 2541.12  3136.07 2909.10  2940.95
## G11:irrigado  6854.880 1888.72290 5 331.656 3966.33  8867.09 6210.41  7225.02
## G11:sequia    2062.412  317.51100 5 331.656 1556.38  2301.31 1942.23  2237.88
## G12:irrigado  7417.258  946.24681 5 331.656 6111.43  8603.78 7164.03  7194.26
## G12:sequia    2446.404   37.06811 5 331.656 2400.00  2487.78 2425.26  2438.98
## G13:irrigado  8672.380 1015.60193 5 331.656 7180.79  9743.70 8256.98  8750.00
## G13:sequia    3126.100   47.70803 5 331.656 3062.34  3191.97 3110.00  3120.00
## G14:irrigado  8384.132 1473.21710 5 331.656 6049.52  9776.01 7895.00  8978.89
## G14:sequia    3514.338  217.30731 5 331.656 3318.36  3811.99 3326.93  3449.76
## G15:irrigado  6367.026  107.45072 5 331.656 6270.00  6522.46 6302.79  6304.88
## G15:sequia    1580.506  248.79682 5 331.656 1176.63  1814.84 1560.00  1601.06
##                   Q75
## G01:irrigado  7750.00
## G01:sequia    3100.00
## G02:irrigado  6478.14
## G02:sequia    2966.18
## G03:irrigado  5450.00
## G03:sequia    2147.55
## G04:irrigado 10305.61
## G04:sequia    3218.63
## G05:irrigado  9793.99
## G05:sequia    1821.46
## G06:irrigado  7864.08
## G06:sequia    3450.00
## G07:irrigado  1607.25
## G07:sequia     811.45
## G08:irrigado  7469.58
## G08:sequia    2550.51
## G09:irrigado 10919.31
## G09:sequia    3235.10
## G10:irrigado  6028.93
## G10:sequia    3096.00
## G11:irrigado  8005.55
## G11:sequia    2274.26
## G12:irrigado  8012.79
## G12:sequia    2480.00
## G13:irrigado  9430.43
## G13:sequia    3146.19
## G14:irrigado  9221.24
## G14:sequia    3664.65
## G15:irrigado  6435.00
## G15:sequia    1750.00
## 
## $comparison
## NULL
## 
## $groups
##                    lfa groups
## G09:irrigado 10287.712      a
## G04:irrigado  9668.932     ab
## G05:irrigado  8878.756    abc
## G13:irrigado  8672.380    abc
## G14:irrigado  8384.132    bcd
## G06:irrigado  7455.364    cde
## G12:irrigado  7417.258    cde
## G01:irrigado  7377.892    cde
## G08:irrigado  7286.826    cde
## G11:irrigado  6854.880    def
## G15:irrigado  6367.026     ef
## G02:irrigado  5779.562     ef
## G03:irrigado  5416.770      f
## G10:irrigado  5271.344     fg
## G14:sequia    3514.338     gh
## G06:sequia    3348.074     hi
## G13:sequia    3126.100    hij
## G09:sequia    3073.322    hij
## G01:sequia    3039.588    hij
## G04:sequia    2978.712    hij
## G10:sequia    2924.648    hij
## G02:sequia    2717.050    hij
## G12:sequia    2446.404   hijk
## G08:sequia    2373.624   hijk
## G11:sequia    2062.412   hijk
## G03:sequia    2059.052   hijk
## G05:sequia    1783.678   hijk
## G15:sequia    1580.506    ijk
## G07:irrigado  1374.156     jk
## G07:sequia     680.734      k
## 
## attr(,"class")
## [1] "group"

library(tidyverse)

grupos <- tukey_result$groups %>% 
  rownames_to_column("tratamientos") %>% 
  separate(tratamientos, into = c("geno", "riego")
           , sep = ":")

str(grupos)
## 'data.frame':    30 obs. of  4 variables:
##  $ geno  : chr  "G09" "G04" "G05" "G13" ...
##  $ riego : chr  "irrigado" "irrigado" "irrigado" "irrigado" ...
##  $ lfa   : num  10288 9669 8879 8672 8384 ...
##  $ groups: chr  "a" "ab" "abc" "abc" ...
ggplot(grupos, aes(x = geno, y = lfa, fill = riego)) +
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  geom_text(aes(label = groups, y = lfa + 0.05), 
            position = position_dodge(width = 0.9), 
            vjust = 0) +
  labs(x = "Genotipo", y = "LFA", fill = "Riego") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ggtitle("Gráfico de barras: LFA por genotipo y riego")

7.1 emmeans: comparación de medias

modelo <- lme4::lmer(hi ~ (1|bloque) + geno*riego
                     , data = fb)

anova(modelo)
## Analysis of Variance Table
##            npar  Sum Sq  Mean Sq F value
## geno         14 2.70077 0.192912 59.9161
## riego         1 0.12176 0.121758 37.8165
## geno:riego   14 0.07762 0.005544  1.7219

cm1 <- emmeans(modelo, ~ geno | riego) %>% 
  cld(Letters = letters, reversed = T)

cm1
## riego = irrigado:
##  geno emmean     SE   df lower.CL upper.CL .group    
##  G07   0.749 0.0278 65.8   0.6938    0.805  a        
##  G15   0.680 0.0278 65.8   0.6248    0.736  ab       
##  G11   0.645 0.0278 65.8   0.5898    0.701  abc      
##  G03   0.625 0.0278 65.8   0.5695    0.681  abc      
##  G09   0.605 0.0278 65.8   0.5490    0.660   bcd     
##  G05   0.580 0.0278 65.8   0.5249    0.636   bcde    
##  G10   0.555 0.0278 65.8   0.4993    0.610    cdef   
##  G04   0.546 0.0278 65.8   0.4903    0.601    cdefg  
##  G12   0.498 0.0278 65.8   0.4427    0.554     defg  
##  G01   0.472 0.0278 65.8   0.4168    0.528      efgh 
##  G02   0.455 0.0278 65.8   0.3995    0.511       fgh 
##  G14   0.436 0.0278 65.8   0.3807    0.492       fgh 
##  G08   0.429 0.0278 65.8   0.3735    0.485        gh 
##  G13   0.350 0.0278 65.8   0.2946    0.406         h 
##  G06   0.221 0.0278 65.8   0.1653    0.276          i
## 
## riego = sequia:
##  geno emmean     SE   df lower.CL upper.CL .group    
##  G07   0.689 0.0278 65.8   0.6335    0.745  a        
##  G11   0.665 0.0278 65.8   0.6097    0.721  a        
##  G03   0.593 0.0278 65.8   0.5371    0.648  ab       
##  G15   0.590 0.0278 65.8   0.5340    0.645  ab       
##  G10   0.582 0.0278 65.8   0.5261    0.637  ab       
##  G09   0.511 0.0278 65.8   0.4556    0.567   bc      
##  G04   0.486 0.0278 65.8   0.4302    0.541   bc      
##  G05   0.446 0.0278 65.8   0.3908    0.502    cd     
##  G01   0.441 0.0278 65.8   0.3852    0.496    cd     
##  G02   0.402 0.0278 65.8   0.3467    0.458    cde    
##  G12   0.402 0.0278 65.8   0.3467    0.458    cde    
##  G14   0.389 0.0278 65.8   0.3335    0.445    cde    
##  G13   0.346 0.0278 65.8   0.2904    0.402     de    
##  G08   0.315 0.0278 65.8   0.2598    0.371      e    
##  G06   0.136 0.0278 65.8   0.0807    0.192       f   
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## P value adjustment: tukey method for comparing a family of 15 estimates 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.

cm2 <- emmeans(modelo, ~ riego | geno) %>% 
  cld(Letters = letters, reversed = T)
cm2
## geno = G01:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.472 0.0278 65.8   0.4168    0.528  a    
##  sequia    0.441 0.0278 65.8   0.3852    0.496  a    
## 
## geno = G02:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.455 0.0278 65.8   0.3995    0.511  a    
##  sequia    0.402 0.0278 65.8   0.3467    0.458  a    
## 
## geno = G03:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.625 0.0278 65.8   0.5695    0.681  a    
##  sequia    0.593 0.0278 65.8   0.5371    0.648  a    
## 
## geno = G04:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.546 0.0278 65.8   0.4903    0.601  a    
##  sequia    0.486 0.0278 65.8   0.4302    0.541  a    
## 
## geno = G05:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.580 0.0278 65.8   0.5249    0.636  a    
##  sequia    0.446 0.0278 65.8   0.3908    0.502   b   
## 
## geno = G06:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.221 0.0278 65.8   0.1653    0.276  a    
##  sequia    0.136 0.0278 65.8   0.0807    0.192   b   
## 
## geno = G07:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.749 0.0278 65.8   0.6938    0.805  a    
##  sequia    0.689 0.0278 65.8   0.6335    0.745  a    
## 
## geno = G08:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.429 0.0278 65.8   0.3735    0.485  a    
##  sequia    0.315 0.0278 65.8   0.2598    0.371   b   
## 
## geno = G09:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.605 0.0278 65.8   0.5490    0.660  a    
##  sequia    0.511 0.0278 65.8   0.4556    0.567   b   
## 
## geno = G10:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  sequia    0.582 0.0278 65.8   0.5261    0.637  a    
##  irrigado  0.555 0.0278 65.8   0.4993    0.610  a    
## 
## geno = G11:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  sequia    0.665 0.0278 65.8   0.6097    0.721  a    
##  irrigado  0.645 0.0278 65.8   0.5898    0.701  a    
## 
## geno = G12:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.498 0.0278 65.8   0.4427    0.554  a    
##  sequia    0.402 0.0278 65.8   0.3467    0.458   b   
## 
## geno = G13:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.350 0.0278 65.8   0.2946    0.406  a    
##  sequia    0.346 0.0278 65.8   0.2904    0.402  a    
## 
## geno = G14:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.436 0.0278 65.8   0.3807    0.492  a    
##  sequia    0.389 0.0278 65.8   0.3335    0.445  a    
## 
## geno = G15:
##  riego    emmean     SE   df lower.CL upper.CL .group
##  irrigado  0.680 0.0278 65.8   0.6248    0.736  a    
##  sequia    0.590 0.0278 65.8   0.5340    0.645   b   
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.

cm3 <- emmeans(modelo, ~ riego * geno) %>% 
  cld(Letters = letters, reversed = T)
cm3
##  riego    geno emmean     SE   df lower.CL upper.CL .group          
##  irrigado G07   0.749 0.0278 65.8   0.6938    0.805  a              
##  sequia   G07   0.689 0.0278 65.8   0.6335    0.745  ab             
##  irrigado G15   0.680 0.0278 65.8   0.6248    0.736  abc            
##  sequia   G11   0.665 0.0278 65.8   0.6097    0.721  abc            
##  irrigado G11   0.645 0.0278 65.8   0.5898    0.701  abcd           
##  irrigado G03   0.625 0.0278 65.8   0.5695    0.681  abcde          
##  irrigado G09   0.605 0.0278 65.8   0.5490    0.660   bcdef         
##  sequia   G03   0.593 0.0278 65.8   0.5371    0.648   bcdefg        
##  sequia   G15   0.590 0.0278 65.8   0.5340    0.645   bcdefg        
##  sequia   G10   0.582 0.0278 65.8   0.5261    0.637   bcdefgh       
##  irrigado G05   0.580 0.0278 65.8   0.5249    0.636   bcdefgh       
##  irrigado G10   0.555 0.0278 65.8   0.4993    0.610   bcdefghi      
##  irrigado G04   0.546 0.0278 65.8   0.4903    0.601    cdefghi      
##  sequia   G09   0.511 0.0278 65.8   0.4556    0.567     defghij     
##  irrigado G12   0.498 0.0278 65.8   0.4427    0.554      efghij     
##  sequia   G04   0.486 0.0278 65.8   0.4302    0.541       fghijk    
##  irrigado G01   0.472 0.0278 65.8   0.4168    0.528       fghijkl   
##  irrigado G02   0.455 0.0278 65.8   0.3995    0.511        ghijkl   
##  sequia   G05   0.446 0.0278 65.8   0.3908    0.502         hijklm  
##  sequia   G01   0.441 0.0278 65.8   0.3852    0.496          ijklm  
##  irrigado G14   0.436 0.0278 65.8   0.3807    0.492          ijklm  
##  irrigado G08   0.429 0.0278 65.8   0.3735    0.485          ijklm  
##  sequia   G02   0.402 0.0278 65.8   0.3467    0.458           jklm  
##  sequia   G12   0.402 0.0278 65.8   0.3467    0.458           jklm  
##  sequia   G14   0.389 0.0278 65.8   0.3335    0.445           jklm  
##  irrigado G13   0.350 0.0278 65.8   0.2946    0.406            klmn 
##  sequia   G13   0.346 0.0278 65.8   0.2904    0.402             lmn 
##  sequia   G08   0.315 0.0278 65.8   0.2598    0.371              mn 
##  irrigado G06   0.221 0.0278 65.8   0.1653    0.276               no
##  sequia   G06   0.136 0.0278 65.8   0.0807    0.192                o
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## P value adjustment: tukey method for comparing a family of 30 estimates 
## significance level used: alpha = 0.05 
## NOTE: If two or more means share the same grouping symbol,
##       then we cannot show them to be different.
##       But we also did not show them to be the same.

7.2 grafico

dtcm <- as.data.frame(cm2) %>% 
  rename(sig = ".group")

ggplot(dtcm, aes(x = geno, y = emmean, fill = riego)) +
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  geom_text(aes(label = sig, y = emmean*1.05),
            position = position_dodge(width = 0.9),
            vjust = 0) +
  labs(x = "Genotipo", y = "HI", fill = "Riego") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  ggtitle("Gráfico de barras: HI por genotipo y riego")

8 Análisis multivariado

str(fb)
## tibble [150 × 18] (S3: tbl_df/tbl/data.frame)
##  $ riego  : chr [1:150] "sequia" "sequia" "irrigado" "sequia" ...
##  $ geno   : chr [1:150] "G01" "G02" "G01" "G02" ...
##  $ block  : num [1:150] 2 4 3 1 2 5 1 4 2 1 ...
##  $ bloque : chr [1:150] "II" "IV" "III" "I" ...
##  $ spad_29: num [1:150] 56.3 52.7 49.2 55.5 58.2 43.5 57.4 56.1 61 60.3 ...
##  $ spad_83: num [1:150] 41.1 47.9 41.6 44.2 32.6 37.8 42.5 35.9 57.5 41.8 ...
##  $ rwc_84 : num [1:150] 61.5 63.2 67.7 64.9 74.5 ...
##  $ op_84  : num [1:150] -2.43 -3.03 -2.5 -2.4 -2.27 ...
##  $ leafdw : num [1:150] 13.28 9.42 18.22 8.84 14.55 ...
##  $ stemdw : num [1:150] 14.87 8.63 24.19 6.58 12.63 ...
##  $ rootdw : num [1:150] 3.83 2.1 3.16 2 1.83 2.83 2.28 3.65 4.04 4.17 ...
##  $ tubdw  : num [1:150] 19.8 17.7 38 13.5 51.1 ...
##  $ biomdw : num [1:150] 51.8 37.8 83.6 30.9 80.2 ...
##  $ hi     : num [1:150] 0.45 0.43 0.455 0.437 0.638 ...
##  $ ttrans : num [1:150] 4.5 3.54 8.39 2.9 7.37 ...
##  $ wue    : num [1:150] 11.51 10.69 9.97 10.65 10.88 ...
##  $ twue   : num [1:150] 4.4 4.99 4.53 4.65 6.94 ...
##  $ lfa    : num [1:150] 2900 2619 7579 2450 5413 ...

8.1 Correlación

library(psych)

fb %>% 
  select_if(is.numeric) %>% 
  dplyr::select(!c("block")) %>% 
  pairs.panels(x = .
               , hist.col="red"
               , pch = 21
               , stars = TRUE
               , scale = FALSE
               , lm = TRUE
               ) 

8.2 PCA: Análisis de componentes principales

library(FactoMineR)

mv <- fb %>% 
  group_by(riego, geno) %>% 
  summarise(across(where(is.numeric), ~ mean(., na.rm = TRUE))) %>% 
  PCA(scale.unit = T, quali.sup = c(1:4), graph = F)


p1 <- plot(mv
     , choix="ind"
     , habillage=1
     , label = "ind"
     )


p2 <- plot(mv
     , choix="var")

list(p1, p2) %>% 
  plot_grid(plotlist = ., nrow = 1)

9 Graficos en ggplot2

9.1 Data cruda

9.1.1 Box plot

p1 <- fb %>% 
  ggplot(data = ., aes(x = geno, y = hi, fill = riego)) +
   geom_boxplot() +
  labs(x = "Genotipos"
       , y = "Indice de cosecha"
       , fill = "Tratamiento" 
       , title ="Eficiencia de uso de agua en papa"
       , subtitle = "Indice de cosecha"
       , caption = "n = 150", 
       ) +
  theme_classic() +
  theme(plot.title = element_text(hjust = 0.5))
p1

9.2 Scater plot

p2 <- fb %>% 
  ggplot(data = .
         , aes(x = twue, y = hi, color = riego)) +
  geom_point() +
  geom_smooth(method = lm) +
    labs(x = "Efiencia de uso de agua de tuberculo"
       , y = "Indice de cosecha"
       , color = "Tratamiento" 
       , title ="Eficiencia de uso de agua en papa"
       , subtitle = "Indice de cosecha vs Efiencia de uso de agua de tuberculo"
       , caption = "n = 150", 
       ) +
  theme_bw()

p2

9.3 Datos resumidos

modelo <- lm(lfa ~  bloque + riego*geno
          , data = fb)

anova(modelo)
## Analysis of Variance Table
## 
## Response: lfa
##             Df    Sum Sq   Mean Sq   F value              Pr(>F)    
## bloque       4   3435339    858835    1.5616              0.1892    
## riego        1 788556926 788556926 1433.7957 <0.0000000000000002 ***
## geno        14 261729564  18694969   33.9922 <0.0000000000000002 ***
## riego:geno  14 108147972   7724855   14.0457 <0.0000000000000002 ***
## Residuals  116  63797516    549979                                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

library(agricolae)

tukey <- HSD.test(modelo
                  , c("geno", "riego")
                  , group = TRUE)

grupos <- tukey_result$groups %>% 
  rownames_to_column("tratamientos") %>% 
  separate(tratamientos, into = c("geno", "riego")
           , sep = ":")
p3 <- grupos %>% 
  ggplot(data = .
         , aes(x = geno, y = lfa, fill = riego)) +
  geom_col(position = position_dodge2(preserve = "single"))

p3

library(psych)

p4 <- function() {
  
    fb %>% 
  select_if(is.numeric) %>% 
  dplyr::select(!c("block")) %>% 
  pairs.panels(x = .
               , hist.col="red"
               , pch = 21
               , stars = TRUE
               , scale = FALSE
               , lm = TRUE
               ) 
}
  
p4
## function() {
##   
##     fb %>% 
##   select_if(is.numeric) %>% 
##   dplyr::select(!c("block")) %>% 
##   pairs.panels(x = .
##                , hist.col="red"
##                , pch = 21
##                , stars = TRUE
##                , scale = FALSE
##                , lm = TRUE
##                ) 
## }

10 Imagenes in grids

library(cowplot)

plot <- list(p1, p2, p3, p4) %>% 
  plot_grid(plotlist = .
            , ncol = 2
            , labels = "auto"
            )

ggsave2(filename = "plot-01.jpg", units = "cm"
        , width = 30*2, height = 15*2.5)

include_graphics("plot-01.jpg")